home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #49 (Oct 89) / SC #49.sit / Jorgs Source / FillRRect.c next >
Text File  |  1989-08-18  |  1KB  |  76 lines

  1. /*    
  2.  *        FillRoundRect class
  3.  *
  4.  *            © Joerg Langowski/MacTutor 1989
  5.  *
  6.  *    SuperClasses :
  7.  *
  8.  *  Instance Vars :
  9.  *
  10.  *    Class Vars :
  11.  *    
  12.  *    Methods :
  13.  *
  14.  *    Class Methods :
  15.  *
  16.  */
  17.  
  18. #include "oic.h"
  19. #include "generics.h"
  20.  
  21. class  FillRRect;    
  22.  
  23. struct FillRRect_i    /* FillRRect instance structure        */
  24. {
  25.     Rect    myRect;
  26.     int        ovalWidth,ovalHeight;
  27.     Pattern    *pat;
  28. };
  29. typedef struct FillRRect_i FillRRect_i;
  30.  
  31. /* -------------------- FillRRect Instance methods ------------------- */
  32.  
  33. static object
  34. _new(self, r, ra)
  35.     object self;
  36.     FillRRect_i    *r;
  37.     struct {
  38.         double    top;
  39.         double    left;
  40.         double    bottom;
  41.         double    right;
  42.         double    ovalWidth;
  43.         double    ovalHeight;
  44.         Pattern  *pat;
  45.             }    *ra;
  46. {
  47.     r->myRect.top = ra->top;
  48.     r->myRect.left = ra->left;
  49.     r->myRect.bottom = ra->bottom;
  50.     r->myRect.right = ra->right;
  51.     r->ovalWidth = ra->ovalWidth;
  52.     r->ovalHeight = ra->ovalHeight;
  53.     r->pat = ra->pat;
  54.     return Super(self);
  55. }
  56.  
  57. static
  58. _draw(self, r)
  59.     object self;
  60.     FillRRect_i    *r;
  61. {    
  62.     FillRoundRect(&r->myRect,r->ovalWidth,r->ovalHeight,r->pat);
  63. }
  64.  
  65. /* ------------------- Init the FillRRect class ---------------------- */
  66.  
  67. InitFillRRect()
  68. {
  69.     FillRRect = NewClass(sizeof(FillRRect_i), 0, "FillRRect", END);
  70.     AddMethods(FillRRect,
  71.         newGeneric,     _new,
  72.         drawGeneric,     _draw,
  73.         END);
  74. }
  75.  
  76.